package org.baojie.raft.message.info;

public interface Message {

    default Type type() {
        return Type.Unknown;
    }


    enum Type {

        Ping(0, "heart beat ping"),
        Pong(1, "heart beat pong"),
        AskVote(2, "vote request"),
        AnsVote(3, "vote response"),

        Unknown(-1, "unknown message type");

        private final int code;
        private final String desc;

        Type(int code, String desc) {
            this.code = code;
            this.desc = desc;
        }

        public int getCode() {
            return code;
        }

        public String getDesc() {
            return desc;
        }
    }
}
